package pathUtil;

import java.io.File;
import java.io.IOException;

/**
 * @Author: WangYongGan
 * @Date: 2021/11/9 21:06
 * @Description:
 */
public class PathUtils {
    public static void testPath(){
        String path="D:\\t.pdf";
        int i = path.lastIndexOf(".");
        System.out.println(i);
        String substring = path.substring(i);
        System.out.println(substring);
    }
    public static void read(String path){
        File file=new File(path);
        if(!file.exists())
            System.out.println("不存在");
    }
    public static String prefixDian(String path){
        String substring = path.substring(0, !path.contains(".") ?path.length():path.indexOf("."));
        System.out.println(substring);
        return substring;
    }
    public static void path() throws IOException {
        String path="test11.txt";
        File file=new File(path);//基于projectPath:
        System.out.println(System.getProperty("user.dir")); // 基于  /r
        Long a=new Long(2);a.hashCode();
        System.out.println(ClassLoader.getSystemResource("/"));
//        PathUtils=new PathUtils();
        System.out.println(PathUtils.class.getResource("/"));//   /root/
//        System.out.println(PathUtils.class.getName().fir);

        if(!file.exists())
            file.createNewFile();
    }  public static String suffixSpot(String path){
        String substring = path.substring(!path.contains(".") ? 0 : path.lastIndexOf(".") + 1, path.length());
        System.out.println(substring);
        return substring;
    }
    public static void main(String[] args) throws IOException {
        path();
//        suffixSpot("www");
//        System.out.println("/"=="\\");
        File file=new File("test111.txt");
        System.out.println(file.exists());
        System.out.println(file.getAbsolutePath());
    }

}
